<template>
  <el-dialog
    v-model="model"
    :close-on-click-modal="false"
    :title="title"
    width="415px"
    @close="model = false"
  >
    <div class="content">
      确认要删除当前白名单数据吗？
    </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="model = false">取消</el-button>
        <el-button type="primary" @click="delWhiteListFn">
          确认
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import { ref } from 'vue'
import { delWhiteListApi } from '@/api/whiteList/management'

export default {
  emits: ['refresh-list'],
  setup(props, { emit }) {
    // 列表刷新
    const model = ref(false)
    const title = ref('是否删除')
    const id = ref()

    const show = rowId => {
      model.value = true
      id.value = rowId
    }

    const delWhiteListFn = async() => {
      const res = await delWhiteListApi(id.value)
      console.log('删除res', res)
      if (!res) {
        ElMessage.success('删除成功')
        model.value = false
        emit('refresh-list')
      }
    }

    return {
      model,
      title,
      show,
      delWhiteListFn
    }
  }
}

</script>

<style scoped lang="scss">
.content {
  padding: 14px 0 20px 10px;
  font-size: 16px;
  font-weight: 500;
  color: #333;
}
</style>
